package com;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.util.Enumeration;
import com.main;

@WebServlet(name = "loginServlet")
public class loginServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("post");
        Users users=new Users(request.getParameter("username"),request.getParameter("password"),request.getParameter("sex"),request.getParameter("email"));
        System.out.println(users.getUsername());
        System.out.println(users.getPassword());
        System.out.println(users.getSex());
        System.out.println(users.getEmail());

    }
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("get");
        Users users=new Users(request.getParameter("username"),request.getParameter("password"),request.getParameter("sex"),request.getParameter("email"));
        System.out.println(users.getUsername());
        System.out.println(users.getPassword());
        System.out.println(users.getSex());
        System.out.println(users.getEmail());
        users.save();
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out=response.getWriter();
        out.write("<font style='color:red'>"+users.getUsername()+"注册成功!!!</font>");
    }
}
